package rabbit.dead;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import rabbit.util.RabbitMqUtils;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Consumer
 * Package: rabbit.dead
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-10-26
 * Time: 21:47
 */

public class Consumer {

    //接收死信的消息 简单接收即可
    //私信队列
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws IOException, TimeoutException {

        Channel chanel = RabbitMqUtils.getChanel();

        System.out.println("等待接收死信消息: ....");

        DeliverCallback deliverCallback = (consumerTag,mes)->{
            System.out.println("接收到消息是: " + new String(mes.getBody()));
        };

        chanel.basicConsume(DEAD_QUEUE,true,deliverCallback,consumerTag -> {});

    }

}
